package com.liehu.user.controller;

import com.liehu.user.pojo.Role;
import com.liehu.user.service.RoleService;
import entity.Result;
import entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
@CrossOrigin //跨域处理
@Api(value = "/role",description = "角色")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @ApiOperation(value = "查询所有", notes = "查询所有")//描述
    @GetMapping()
    public Result findAll(){
        return  new Result(true, StatusCode.OK,"查询成功！",roleService.findAll());
    }


    @ApiOperation(value = "根据角色id查询", notes = "根据角色id查询")//描述
    @GetMapping("/{id}")
    public Result findById(@PathVariable String id){
        Role byId = roleService.findById(id);
        return  new Result(true, StatusCode.OK,"查询成功！");
    }


}
